package com.td.module.equipment.convert.waterpump;

import com.td.module.equipment.controller.admin.waterpump.vo.WaterPumpRespVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.HashMap;
import java.util.List;

@Mapper
public interface WaterPumpConvert {

    WaterPumpConvert INSTANCE = Mappers.getMapper(WaterPumpConvert.class);

    @Mappings({
            @Mapping(expression = "java(map.get(\"equipment_id\").toString())", target = "equipmentId"),
            @Mapping(expression = "java(map.get(\"equipment_name\").toString())", target = "equipmentName"),
            @Mapping(expression = "java(Integer.parseInt(map.get(\"equipmentType\").toString()))", target = "equipmentType"),
            @Mapping(expression = "java(map.get(\"equipment_type_name\").toString())", target = "equipmentTypeName"),
            @Mapping(expression = "java(map.get(\"equipment_type_icon\").toString())", target = "equipmentTypeIcon"),
            @Mapping(expression = "java(map.get(\"equipment_code\").toString())", target = "equipmentCode"),
            @Mapping(expression = "java(map.get(\"value\").toString())", target = "value"),
            @Mapping(expression = "java(map.get(\"value2\").toString())", target = "value2"),
            @Mapping(expression = "java(map.get(\"value_cuur\").toString())", target = "valueCuur"),
            @Mapping(expression = "java(map.get(\"gateway_mac\").toString())", target = "gatewayMac"),
            @Mapping(expression = "java(map.get(\"com_type\").toString())", target = "comType"),
            @Mapping(expression = "java(map.get(\"battery\").toString())", target = "battery"),
            @Mapping(expression = "java(map.get(\"create_time\").toString())", target = "createTime"),
            @Mapping(expression = "java(map.get(\"update_time\").toString())", target = "updateTime"),
            @Mapping(expression = "java(Integer.parseInt(map.get(\"state\").toString()))", target = "state")
    })
    WaterPumpRespVO convert(HashMap<String, Object> map);

    List<WaterPumpRespVO> convertList(List<HashMap<String, Object>> list);
}
